package com.sky.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.sky.entity.DishFlavor;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document(indexName = "dishvo")
public class DishVO implements Serializable {

    @Id
    private Long id;

    //菜品名称
    @Field(type = FieldType.Text)
    private String name;

    //菜品分类id
    @Field(type = FieldType.Long)
    private Long categoryId;

    //菜品价格
    @Field(type = FieldType.Double)
    private BigDecimal price;

    //图片
    @Field(type = FieldType.Keyword)
    private String image;

    //描述信息
    @Field(type = FieldType.Keyword)
    private String description;

    //0 停售 1 起售
    @Field(type = FieldType.Integer)
    private Integer status;

    //更新时间
    @Field(type = FieldType.Date,format = DateFormat.date_hour_minute_second)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime updateTime;

    //分类名称
    @Field(type = FieldType.Text)
    private String categoryName;

    //菜品关联的口味
    @Field(type = FieldType.Nested)
    private List<DishFlavor> flavors = new ArrayList<>();

    //private Integer copies;
}
